﻿using Newtonsoft.Json;
using System.Diagnostics;
using System.Reflection;
namespace CSConfig
{

    public interface IItem
    {
        //[JsonIgnore]
        string Help  => null;
        //[JsonIgnore]
        string DisplayName => null;
        //[JsonIgnore]
        bool IsVisible => true;
        //[JsonIgnore]
        bool IsReadOnly => false;
    }
    
    public class Config<T>: IItem
    {
        //[JsonIgnore]
        public string MacroName { get; set; }
        public T Value { get; set; }
        //[JsonIgnore]
        public bool IsHexShow { get; set; }
        //[JsonIgnore]
        public string Help { get; set; }
        //[JsonIgnore]
        public string DisplayName { get; set; }
        //[JsonIgnore]
        public bool IsVisible { get; set; }
        //[JsonIgnore]
        public bool IsReadOnly { get; set; }
        public override string ToString()
        {
            return DisplayName;
        }

    }
    public class ListItem : IItem
    {
        public List<IItem> Items { get; set; }
        //[JsonIgnore]
        public string Help { get; set; }
        //[JsonIgnore]
        public string DisplayName { get; set; }
        //[JsonIgnore]
        public bool IsVisible { get; set; }
        //[JsonIgnore]
        public bool IsReadOnly { get; set; }
        //[JsonIgnore]
        public bool CanAddByUser { get; set; } = false;
        public override string ToString()
        {
            return DisplayName;
        }
    }

    public class Choice : IItem
    {
        public IItem SelectedItem { get; set; }
        //[JsonIgnore]
        public List<IItem> Items { get; set; }
        //[JsonIgnore]
        public string Help { get; set; }
        //[JsonIgnore]
        public string DisplayName { get; set; }
        //[JsonIgnore]
        public bool IsVisible { get; set; }
        //[JsonIgnore]
        public bool IsReadOnly { get; set; }
        //[JsonIgnore]
        public bool CanAddByUser { get; set; } = false;
        public override string ToString()
        {
            return DisplayName;
        }
        
    }


    public interface IMenu : IItem
    {
        public string ToString()
        {
            return DisplayName;
        }
        public void ItemValueChanged(IItem item);
    }

    [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
    public class ItemConfigAttribute : Attribute
    {
        
    }

    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
    public class MainMenuAttribute : Attribute
    {

    }

    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
    public class CodeGenAttribute : Attribute
    {

    }

    public interface IHost
    {
        public void WriteLine(string? format, params string[] d);
        public void WriteLine(string? msg);
    }
    public static class Host
    {
        public static IHost? HostInstance { get; set; }
        public static void WriteLine(string format, params string[] d)
        {
            HostInstance?.WriteLine(format, d);
        }
        public static void WriteLine(string? format)
        {
            HostInstance?.WriteLine(format);
        }
    }
}
